﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;


namespace deneme
{
    public partial class UserForm : Form
    {
        SqlConnection con = new SqlConnection(ClassSqlConnection.ConnectionString);
        ClassFillComboBox cfcb = new ClassFillComboBox();
        AdminForm ad = new AdminForm();
        ClassFillComboBox2 cfcb2 = new ClassFillComboBox2();


        public UserForm()
        {
            InitializeComponent();
        }
       //int S1, S2, S3, S4, S5, S6;
        //private string N1, N2, N3, N4, N5, N6;
        
        private void txtSure_TextChanged(object sender, EventArgs e)
        {
        }
        int Kg;
        int Kasa;
      

        private void textBox1_TextChanged_1(object sender, EventArgs e)
        {
        }



        private void button1_Click(object sender, EventArgs e)
        {
            //string strQuery = null;
            //string sehir1 = null;
            //string sehir2 = null;
            //string[] sehirler = new string[74];
            //Dictionary<string, Node> _dictNodes = new Dictionary<string, Node>();
            //if (con.State == ConnectionState.Closed) con.Open();

            //for (int i = 1; i < 75; i++)
            //{
            //    sehir1 = "SELECT SehirAd FROM tblSehir WHERE ID = " + i + " ";
            //    SqlCommand sqcom1 = new SqlCommand(sehir1, con);
            //    sehirler[i - 1] = sqcom1.ExecuteScalar().ToString();
            //    _dictNodes.Add(sehirler[i - 1], new Node(sehirler[i - 1]));
            //}

            //List<Node> _nodes = new List<Node>();
            //foreach (Node n in _dictNodes.Values)
            //{
            //    _nodes.Add(n);
            //}

            //List<Edge> _edges = new List<Edge>();

            //for (int i = 1; i < 75; i++)
            //{

            //    for (int j = 1; j < 75; j++)
            //    {
            //        strQuery = "SELECT  [" + j + "]  FROM tblMesafe WHERE ID = " + i + " ";

            //        SqlCommand sqcom = new SqlCommand(strQuery, con);

            //        if (sqcom.ExecuteScalar().ToString() != "")
            //        {

            //            //Sehir1
            //            sehir1 = "SELECT SehirAd FROM tblSehir WHERE ID = " + i + " ";
            //            SqlCommand sqcom1 = new SqlCommand(sehir1, con);
            //            sehir1 = sqcom1.ExecuteScalar().ToString();

            //            //Sehir2
            //            sehir2 = "SELECT SehirAd FROM tblSehir WHERE ID = " + j + " ";
            //            SqlCommand sqcom2 = new SqlCommand(sehir2, con);
            //            sehir2 = sqcom2.ExecuteScalar().ToString();
            //            //DugumEkle(sehir1, sehir2, Convert.ToInt32(sqcom.ExecuteScalar().ToString()));

            //            _edges.Add(new Edge(_dictNodes[sehir1], _dictNodes[sehir2], Convert.ToInt32(sqcom.ExecuteScalar().ToString())));
            //        }
            //    }
            //}
      
                
       
                kalkis = cb1.SelectedItem.ToString();
                varis = cb2.SelectedItem.ToString();

                ClassFillCity cfc = new ClassFillCity();
                cfc.sehirekle(kalkis, varis);

            

                try
                {
                    if (con.State == ConnectionState.Closed)
                    {
                        con.Open();
                    }
                
                    SqlCommand cmd = new SqlCommand("sp$UyeIstek", con);
                    cmd.CommandType = CommandType.StoredProcedure;
                    cmd.Parameters.AddWithValue("@KullaniciAd", txtUyeAd.Text);
                    cmd.Parameters.AddWithValue("@KullaniciSifre", txtUyeSoyad.Text);
                    cmd.Parameters.AddWithValue("@UyeEPosta", txtEPosta.Text);
                    cmd.Parameters.AddWithValue("@UyeFirma", txtFirma.Text);
                    cmd.Parameters.AddWithValue("@KalkisYeri", cb1.Text);
                    cmd.Parameters.AddWithValue("@VarisYeri", cb2.Text);
                    cmd.Parameters.AddWithValue("@GidilecekYol",cfc.gidilecekyol);
                    cmd.Parameters.AddWithValue("@ToplamMesafe", cfc.mesafe);
                    cmd.Parameters.AddWithValue("@TasinacakUrun", cb3.Text);
                  
                    cmd.Parameters.AddWithValue("@KoliSayisi",txtAdet.Text);
                  

                    cmd.ExecuteNonQuery();
                    MessageBox.Show("İstek Başarıyla oluşturuldu!");


                }
                catch (Exception)
                {

                    MessageBox.Show("sp hatası");
                }
        }
        private void UserForm_Load(object sender, EventArgs e)
        {
            //**
            this.Text = "            *** YURT İÇİ KARGOO ***               ";
            timer1.Start();
            //**
            cb1.Items.Add(cb1.Text);
            cb2.Items.Add(cb2.Text);
           // cb3.Items.Add(cb3.Text);
           // cb4.Items.Add(cb4.Text);

            cfcb2.comboboxdoldurucu(cb1, "tblSehir", 1);
            cfcb2.comboboxdoldurucu(cb2, "tblSehir", 1);
            cfcb.comboboxdoldurucu(cb3, "tblUrunler", 1);
        }
        string kalkis;
        string varis;

        private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
        {
            
          
        }
        private void cb2_SelectedIndexChanged(object sender, EventArgs e)
        {

           
        }

        private void txtMesafe_TextChanged(object sender, EventArgs e)
        {

        }

        private void textBox2_TextChanged(object sender, EventArgs e)
        {
        }
        private void textBox1_TextChanged(object sender, EventArgs e)
        {
          
        }

        private void button2_Click(object sender, EventArgs e)
        {
           

        }

        private void button2_Click_1(object sender, EventArgs e)
        {
         
   


        }

      

        private void cb4_SelectedIndexChanged(object sender, EventArgs e)
        {
          
        }

        private void txtYol_TextChanged(object sender, EventArgs e)
        {

        }

        private void timer1_Tick(object sender, EventArgs e)
        {
              

        }

        private void timer1_Tick_1(object sender, EventArgs e)
        {
            this.Text = this.Text.Substring(1) + this.Text.Substring(0, 1);
        }

        private void button2_Click_2(object sender, EventArgs e)
        {
            Anasayfa ana = new Anasayfa();
            ana.Show();
            this.Hide();
        }
    }
}

